home *** CD-ROM | disk | FTP | other *** search
/ Programming Languages Suite / ProgramD2.iso / Borland / Borland C++ V5.02 / OWLINC.PAK / DRAGLIST.H < prev    next >
C/C++ Source or Header  |  1997-05-06  |  3KB  |  114 lines

  1. //----------------------------------------------------------------------------
  2. // ObjectWindows
  3. // Copyright (c) 1995, 1997 by Borland International, All Rights Reserved
  4. //
  5. //$Revision:   10.5  $
  6. //
  7. // Definition of class TDragList, a listbox that has dragging capabilities for
  8. // items.
  9. //
  10. // The owner of a TDragList should have in its response table:
  11. //  EV_REGISTERED(DRAGLISTMSGSTRING, xxx)
  12. //----------------------------------------------------------------------------
  13. #if !defined(OWL_DRAGLIST_H)
  14. #define OWL_DRAGLIST_H
  15.  
  16. #if !defined(OWL_DEFS_H)
  17. # include <owl/defs.h>
  18. #endif
  19. #if !defined(BI_PLAT_WIN32)
  20. # error OWL: draglist.h supports only WIN32 targets
  21. #endif
  22.  
  23. #if !defined(OWL_EVENTHAN_H)
  24. # include <owl/eventhan.h>
  25. #endif
  26. #if !defined(OWL_LISTBOX_H)
  27. # include <owl/listbox.h>
  28. #endif
  29. #if !defined(OWL_COMMCTRL_H)
  30. # include <owl/commctrl.h>
  31. #endif
  32.  
  33. #if defined(BI_NAMESPACE)
  34. namespace OWL {
  35. #endif
  36.  
  37. // Generic definitions/compiler options (eg. alignment) preceeding the 
  38. // definition of classes
  39. #include <services/preclass.h>
  40.  
  41. //
  42. // class TDragList
  43. // ~~~~~ ~~~~~~~~~
  44. // A draggable list box.
  45. //
  46. class _OWLCLASS TDragList : public TListBox {
  47.   public:
  48.  
  49.     // Enumeration used to specify the type of cursor to be displayed
  50.     // during a drag operation. The cursor provides feedback to the user
  51.     // about whether the object being dragged can be dropped and the
  52.     // operation resulting from the drop.
  53.     //
  54.     enum TCursorType {
  55.       dlStop = DL_STOPCURSOR,   // stop cursor - item cannot be dropped now
  56.       dlCopy = DL_COPYCURSOR,   // copy cursor - item dragged will be copied
  57.       dlMove = DL_MOVECURSOR,   // move cursor - item dragged will be moved
  58.     };
  59.  
  60.     // Constructors
  61.     //
  62.     TDragList(TWindow*       parent,
  63.              int             id,
  64.              int x, int y, int w, int h,
  65.              TModule*        module = 0);
  66.  
  67.     TDragList(TWindow* parent, int resourceId, TModule* module = 0);
  68.  
  69.     // Override these virtual functions for handling dragging events
  70.     //
  71.     virtual bool        BeginDrag(int item, const TPoint& point);
  72.     virtual TCursorType Dragging(int item, const TPoint& point);
  73.     virtual void        Dropped(int item, const TPoint& point);
  74.     virtual void        CancelDrag(int item, const TPoint& point);
  75.  
  76.     // Wrappers for the common control functions
  77.     //
  78.     void DrawInsert(int item);
  79.     int  ItemFromPoint(const TPoint& p, bool scroll = true);
  80.  
  81.   protected:
  82.     void SetupWindow();
  83.  
  84.   private:
  85.     TResult DragNotify(TParam1, TParam2);
  86.  
  87.   DECLARE_RESPONSE_TABLE(TDragList);
  88. };
  89.  
  90. //
  91. // class TDragListEventHandler
  92. // ~~~~~ ~~~~~~~~~~~~~~~~~~~~~
  93. // A TEventHandler mix-in.
  94. // This class is designed to handle the drag list notifications and
  95. // forward the messages from the parent window to the TDragList class.
  96. //
  97. class _OWLCLASS TDragListEventHandler : virtual public TEventHandler {
  98.   public:
  99.     TResult DragNotify(TParam1, TParam2);
  100.  
  101.   DECLARE_RESPONSE_TABLE(TDragListEventHandler);
  102. };
  103.  
  104. // Generic definitions/compiler options (eg. alignment) following the 
  105. // definition of classes
  106. #include <services/posclass.h>
  107.  
  108. #if defined(BI_NAMESPACE)
  109. } // namespace OWL
  110. #endif
  111.  
  112. #endif  // OWL_DRAGLIST_H
  113.  
  114.